package com.junzhiit.nengji.cms.web.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.cms.service.GoodsHistoryService;
import com.junzhiit.nengji.cms.web.vo.DataTablesParamVO;
import com.junzhiit.nengji.cms.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/goods/history")
public class GoodsHistoryController extends BaseController {

	@Autowired
	GoodsHistoryService goodsHistoryService;

	@ApiOperation(value = "获取所有商品分析数据")
	@RequestMapping(value = "/analysis", method = RequestMethod.GET)
	public ResultVO getGoodsAnalysis(String sessionId, String startTime, String endTime, String shopId) {
		AssertUtil.notBlank(sessionId, "sessionId is required.");
		AssertUtil.notBlank(startTime, "startTime is required.");
		AssertUtil.notBlank(endTime, "endTime is required.");
		return goodsHistoryService.getGoodsAnalysis(sessionId, startTime, endTime, shopId);
	}

	@ApiOperation(value = "查询所有上架商品的数据分析")
	@RequestMapping(method = RequestMethod.GET)
	public Map<String, Object> getAllGoodsAnalysis(String sessionId, String startTime, String endTime, String shopId,
			DataTablesParamVO dtp) {
		AssertUtil.notBlank(sessionId, "sessionId is required");
		AssertUtil.notBlank(startTime, "startTime is required");
		AssertUtil.notBlank(endTime, "endTime is required");
		return goodsHistoryService.getAllGoodsAnalysis(sessionId, startTime, endTime, shopId, dtp);
	}
}
